package s18.ch21.zadanie;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;

public class MySerialization {

	public static void main(String[] args) throws FileNotFoundException, IOException, ClassNotFoundException {
		Person person = new Person();
		Person person1 = new Person();
		
		person.setName("Marek");
		person.setSurname("Kulka");
		person.setBrand("Ford");
		person1.setName("Marek1");
		person1.setSurname("Kulka1");
		person1.setBrand("Ford1");
		
		ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("person.out"));
		oos.writeObject(person);
		oos.writeObject(person1);
		oos.close();

		ObjectInputStream ois = new ObjectInputStream(new FileInputStream("person.out"));
		Person outperson = (Person) ois.readObject();
		Person readObject = (Person) ois.readObject();
		
		ois.close();
		
		System.out.println(outperson.getName());
		System.out.println(outperson.getSurname());
		System.out.println(outperson.getBrand());
//		System.out.println(o.toString());
	}

}
